home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / Think-Pascal-7.0.cpt / THINK Pascal Interfaces / CursorCtl.p < prev    next >
Encoding:
Text File  |  1991-04-03  |  5.4 KB  |  142 lines  |  [TEXT/PJMM]

  1. {    This file has been processed by The THINK Pascal Source Converter, v1.1.    }
  2.  
  3. {
  4. Created: Tuesday, August 2, 1988 at 12:24 PM
  5.     CursorCtl.p
  6.     Pascal Interface to the Macintosh Libraries
  7.  
  8.     
  9.     <<< CursorCtl - Cursor Control Interface File >>>
  10.     
  11.     
  12.     Copyright Apple Computer, Inc. 1984-1988
  13.     All rights reserved
  14.     
  15.     This file contains:
  16.     
  17.     InitCursorCtl(newCursors) - Init CursorCtl to load the 'acur' resource
  18.     RotateCursor(counter) - Sequence through cursor frames for counter mod 32
  19.     SpinCursor(increment) - Sequence mod 32 incrementing internal counter
  20.     Hide_Cursor() - Hide the current cursor
  21.     Show_Cursor(cursorKind) - Show the cursor
  22. }
  23.  
  24.  
  25. {$IFC UNDEFINED UsingIncludes}
  26. {$SETC UsingIncludes := 0}
  27. {$ENDC}
  28.  
  29.  
  30.     UNIT CursorCtl;
  31.     INTERFACE
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. TYPE
  39.  
  40. { Kinds of cursor supported by CursorCtl }
  41. Cursors = (HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,
  42.     ARROW_CURSOR);
  43.  
  44. acurPtr = ^Acur;
  45. acurHandle = ^acurPtr;
  46. Acur = RECORD
  47.     n: INTEGER;         {Number of cursors ("frames of film")}
  48.     index: INTEGER;     { Next frame to show <for internal use>}
  49.     frame1: INTEGER;    {'CURS' resource id for frame #1}
  50.     fill1: INTEGER;     {<for internal use>}
  51.     frame2: INTEGER;    {'CURS' resource id for frame #2}
  52.     fill2: INTEGER;     {<for internal use>}
  53.     frameN: INTEGER;    {'CURS' resource id for frame #N}
  54.     fillN: INTEGER;     {<for internal use>}
  55.     END;
  56.  
  57.  
  58.  
  59. PROCEDURE InitCursorCtl(newCursors: UNIV acurHandle);
  60. { Initialize the CursorCtl unit. This should be called once prior to calling
  61. RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or
  62. Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the
  63. 'acur' resource and the 'CURS' resources specified by the 'acur' resource
  64. ids.  If any of the resources cannot be loaded, the cursor will not be
  65. changed.
  66.  
  67. The 'acur' resource is assumed to either be in the currently running tool or
  68. application, or the MPW Shell for a tool, or in the System file.  The 'acur'
  69. resource id must be 0 for a tool or application, 1 for the Shell, and 2 for
  70. the System file.
  71.  
  72. If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted
  73. resource designated by the caller and it will be used instead of doing a
  74. GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without
  75. calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for
  76. the user the first time it is called.  However, the possible disadvantage of
  77. using this technique is that the resource memory allocated may have
  78. undesirable affect (fragmentation?) on the application. Using InitCursorCtl
  79. has the advantage of causing the allocation at a specific time determined by
  80. the user.
  81.  
  82. Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.    Specifically,
  83. it changes each FrameN/fillN integer pair to a handle to the corresponding
  84. 'CURS' resource also in memory.  Thus if NewCursors is not NULL when
  85. InitCursorCtl is called, the caller must guarantee NewCursors always points to
  86. a "fresh" copy of an 'acur' resource.  This need only be of concern to a
  87. caller who wants to repeatly use multiple 'acur' resources during execution of
  88. their programs.
  89. }
  90.  
  91. PROCEDURE RotateCursor(counter: LONGINT);
  92. { RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to
  93. animate whatever sequence of cursors set up by InitCursorCtl. The next cursor
  94. ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing
  95. or decrementing index maintained by the caller). A positive counter sequences
  96. forward through the cursors (e.g., it rotates the "beach ball" cursor
  97. clockwise), and a negative cursor sequences through the cursors backwards
  98. (e.g., it rotates the "beach ball" cursor counterclockwise).  Note,
  99. RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  100.   It is assumed the cursor is visible from a prior Show_Cursor call.
  101. }
  102.  
  103. PROCEDURE SpinCursor(increment: INTEGER);
  104. { SpinCursor is similar in function to RotateCursor, except that instead of
  105. passing a counter, an Increment is passed an added to a counter maintained
  106. here.  SpinCursor is provided for those users who do not happen to have a
  107. convenient counter handy but still want to use the spinning "beach ball"
  108. cursor, or any sequence of cursors set up by InitCursorCtl.  A positive 
  109. increment sequences forward through the curos (rotating the "beach ball"
  110. cursor clockwise), and a negative increment sequences backward through the
  111. cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value
  112. for the increment resets the counter to zero.  Note, it is the increment, and
  113. not the value of the counter that determines the sequencing direction of the
  114. cursor (and hence the spin direction of the "beach ball" cursor).
  115. }
  116.  
  117. PROCEDURE Hide_Cursor;
  118. { Hide the cursor if it is showing.This is this unit's call to the Mac
  119. HideCursor routine.Thus the Mac cursor level is decremented by one when this
  120. routine is called.
  121. }
  122.  
  123. PROCEDURE Show_Cursor(cursorKind: Cursors);
  124. { Increment the cursor level, which may have been decremented by Hide_Cursor,
  125. and display the specified cursor if the level becomes 0 (it is never
  126. incremented beyond 0).The CursorKind is the kind of cursor to show.  It is
  127. one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR,
  128. WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is
  129. done for the specified cursor prior to doing a ShowCursor.    HIDDEN_CURSOR just
  130. causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if
  131. there is already a grafPort set up pointed to by 0(A5).
  132. }
  133.  
  134.  
  135.     { UsingCursorCtl }
  136.  
  137.  
  138.     IMPLEMENTATION
  139. END.
  140.  
  141.  
  142.